/* stylelint-disable max-nesting-depth */
@import "~scss/variables";

$sw-search-bar-border-color: var(--color-border-primary-default);
$sw-search-bar-results-background-color: var(--color-elevation-surface-overlay);
$sw-search-bar-border-radius: $border-radius-default;
$sw-search-bar-results-box-shadow: 0 3px 6px 0 var(--color-elevation-shadow-default);
$sw-search-bar-results-z-index: 800;
$sw-search-bar-types-z-index: 900;
$sw-search-bar-z-index: $z-index-search-bar-results;
$sw-search-bar-button-color-text: $color-white;
$sw-search-bar-mobile-box-shadow: 0 3px 3px rgba(0, 0, 0, 30%);
$sw-search-bar-result-color-icon: darken($color-gray-100, 20%);
$sw-search-bar-types-item-hover-color-background: lighten($color-shopware-brand-500, 40%);
$sw-search-bar-types-item-border-radius: $border-radius-default;

.sw-search-bar {
    width: 100%;
    height: 80px;
    z-index: $sw-search-bar-z-index;
    align-content: center;

    .sw-search-bar__button {
        width: 50px;
        height: 50px;
        line-height: 48px;
        display: block;
        background: 0 none;
        color: $sw-search-bar-button-color-text;
        border: 0 none;
        outline: none;
        cursor: pointer;
        -webkit-appearance: none;
        -moz-appearance: none;
    }

    @media screen and (max-width: 500px) {
        background: $color-menu-start;
        border-bottom: 0 none;
        box-shadow: $sw-search-bar-mobile-box-shadow;
    }

    .sw-search-bar__container {
        padding: 15px 0;
        max-width: $content-width;
        margin: 0 auto;
        position: relative;

        @media screen and (max-width: 1360px) {
            padding: 15px;
        }
    }

    .sw-search-bar__mobile-controls {
        display: grid;
        grid-template-columns: auto 1fr auto;
        grid-gap: 5px;
        align-items: center;
    }

    .sw-search-bar__field {
        margin-bottom: 0;
        border: 1px solid $sw-search-bar-border-color;
        border-radius: $sw-search-bar-border-radius;
        background-color: var(--color-elevation-surface-raised);
        padding: 9px 10px;
        position: relative;
        display: flex;
        flex-wrap: nowrap;
        height: 50px;

        &.is--active {
            outline: var(--scale-size-2) solid var(--color-border-brand-selected);
            outline-offset: var(--scale-size-2);
        }

        .sw-search-bar__field-icon {
            position: absolute;
            top: 0;
            bottom: 0;
            height: 100%;
            width: 50px;
            right: 0;
            color: var(--color-icon-primary-default);
            text-align: center;
            line-height: 45px;
            background: 0 none;
            border: 0 none;
            outline: none;
            -moz-appearance: none;
            -webkit-appearance: none;
        }

        .sw-search-bar__field-close {
            display: none;
            cursor: pointer;
        }

        .sw-search-bar__field-search-icon {
            pointer-events: none;
        }

        @media screen and (max-width: 500px) {
            .sw-search-bar__field-close {
                display: block;
            }

            .sw-search-bar__field-search-icon {
                display: none;
            }
        }
    }

    .sw-search-bar__type {
        background-color: darken($color-gray-100, 20%);
        color: $color-white;
        display: inline-block;
        padding: 5px 12px;
        border-radius: $sw-search-bar-border-radius;
        flex-shrink: 0;
        font-weight: $font-weight-semi-bold;
        font-size: $font-size-xs;
    }

    &__type {
        &--v2 {
            background-color: darken($color-gray-100, 20%);
            color: $color-white;
            display: flex;
            align-items: center;
            padding: 5px 12px;
            border-radius: $sw-search-bar-border-radius;
            flex-shrink: 0;
            font-weight: $font-weight-semi-bold;
            font-size: $font-size-xs;

            &:focus-visible {
                outline-offset: var(--scale-size-2);
                outline: var(--scale-size-2) solid var(--color-border-brand-selected);
            }

            .mt-icon {
                width: 16px;
                height: 16px;
                margin-left: 10px;
                padding-top: 6px;
                padding-right: 3px;
                padding-bottom: 4px;
                padding-left: 3px;
            }
        }
    }

    &__footer,
    &__header {
        display: flex;
        justify-content: space-between;
        background-color: var(--color-background-primary-disabled);
        padding: 10px 24px;
    }

    &__header-title {
        font-size: var(--font-size-xs);
        color: var(--color-text-primary-default);
        font-weight: var(--font-weight-semibold);
        line-height: var(--font-line-height-xs);
    }

    &__footer-action-setting {
        cursor: pointer;
    }

    .sw-search-bar__input {
        color: var(--color-text-primary-default);
        flex-grow: 1;
        font-size: var(--font-size-xs);
        line-height: var(--font-line-height-xs);
        padding: 0 40px 0 15px;
        border: 0;
        background: none;
        outline: none;

        &::placeholder {
            color: var(--color-text-tertiary-default);
        }
    }

    .sw-search-bar__controls {
        width: 100px;
    }

    .sw-search-bar__results-column {
        margin-bottom: 16px;
    }

    .sw-search-bar__results-column-header {
        margin-bottom: 10px;
        font-size: var(--font-size-xs);
        line-height: var(--font-line-height-xs);
        font-family: var(--font-family-body);
        font-weight: var(--font-weight-regular);
        color: var(--color-text-primary-default);

        .mt-icon {
            margin-right: 5px;
        }

        .sw-search-bar__types-header-entity {
            font-weight: bold;
            margin-left: 5px;
        }
    }

    .sw-search-bar__results {
        display: grid;
        grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
        grid-gap: 20px;
        position: absolute;
        right: 0;
        left: 0;
        top: 73px;
        z-index: $sw-search-bar-results-z-index;
        padding: 25px;
        min-height: 300px;
        max-height: calc(100vh - 100px);
        overflow-x: hidden;
        overflow-y: auto;
        background-color: $sw-search-bar-results-background-color;
        border: 1px solid $sw-search-bar-border-color;
        border-radius: $sw-search-bar-border-radius;
        box-shadow: $sw-search-bar-results-box-shadow;

        &.is-empty-state {
            min-height: 80px;
        }

        @media screen and (max-width: 1360px) {
            right: 15px;
            left: 15px;
        }

        &--v2 {
            max-height: 633px;
            display: flex;
            flex-direction: column;
            justify-content: space-between;
            overflow: hidden;
            padding: 0;
            grid-gap: 0;

            &.is-empty-state {
                min-height: auto;
            }

            .sw-search-bar__results-wrapper-content {
                overflow: auto;
            }

            .sw-search-bar__shortcut-tip {
                line-height: var(--font-line-height-2xs);
                font-size: var(--font-size-2xs);
                color: var(--color-text-primary-default);
                margin: 0;

                span {
                    text-transform: uppercase;
                    border: 1px solid var(--color-border-primary-default);
                    border-radius: 3px;
                    background-color: var(--color-background-primary-disabled);
                    padding: 0 4px;
                    margin: 0 3px;
                }

                a {
                    font-size: 12px;
                }
            }

            .sw-search-bar__results-column-header {
                display: flex;
                justify-content: space-between;
                background-color: var(--color-background-primary-disabled);
                padding: 10px 24px;
                margin: 0;
            }

            .sw-search-bar__results-column {
                margin-bottom: 8px;
            }

            .sw-search-bar__results-empty-message {
                padding: 32px 24px 26px;
            }
        }
    }

    .sw-search-bar__results-list {
        margin: 0;
        padding: 0;
        list-style: none;
    }

    .sw-search-bar__results-empty-message {
        padding: 10px 16px;

        &--v2 {
            padding: 0;
        }

        .mt-icon {
            color: $sw-search-bar-result-color-icon;
            margin-right: 10px;
        }
    }

    &__types_container,
    &__types_container--v2 {
        position: absolute;
        right: 0;
        left: 0;
        top: 73px;
        z-index: $sw-search-bar-types-z-index;
        padding: 25px;
        overflow-x: hidden;
        overflow-y: auto;
        background-color: $sw-search-bar-results-background-color;
        border: 1px solid $sw-search-bar-border-color;
        border-radius: $sw-search-bar-border-radius;
        box-shadow: $sw-search-bar-results-box-shadow;

        @media screen and (max-width: 1360px) {
            right: 15px;
            left: 15px;
        }
    }

    &__types_container--v2 {
        display: flex;
        flex-direction: column;
        padding: 0;

        .sw-search-bar__type {
            &-item {
                margin: 0;
                display: flex;
                justify-content: space-between;
                align-items: center;
                padding: 3px 30px;

                &.is--active,
                &:hover {
                    border-radius: unset;
                    border: none;
                    background-color: var(--color-background-brand-default);

                    .sw-search-bar__type {
                        &-item-name,
                        &--filter {
                            color: var(--color-text-brand-default);
                        }
                    }
                }
            }

            &--filter {
                font-size: $font-size-xs;
                color: #b3bfcc;
            }
        }

        .sw-search-bar__shortcut-tip {
            line-height: var(--font-line-height-2xs);
            font-size: var(--font-size-2xs);
            color: var(--color-text-primary-default);
            margin: 0;

            span {
                text-transform: uppercase;
                border: 1px solid var(--color-border-primary-default);
                border-radius: 3px;
                background-color: var(--color-background-primary-disabled);
                padding: 0 4px;
                margin: 0 3px;
            }
        }
    }

    &__types_module-filters-container {
        max-width: 240px;

        .sw-search-bar__shortcut-tip span {
            text-transform: lowercase;
        }
    }

    &__type-item-name {
        display: flex;
        align-items: center;
        color: var(--color-text-primary-default);
        font-size: var(--font-size-xs);
        line-height: var(--font-line-height-xs);
        padding: 5px 0;
    }

    &__type-item-icon {
        width: 14px;
        height: 14px;
        margin-right: 12px;
    }

    &__shortcut-tip {
        font-size: $font-size-xs;
        color: lighten($color-darkgray-200, 25%);
        margin: 20px 3px 0;
    }

    &__results-empty-text {
        color: var(--color-text-primary-default);
        font-size: var(--font-size-s);
        line-height: var(--font-line-height-s);
        font-family: var(--font-family-body);
        font-weight: var(--font-weight-semibold);
        letter-spacing: 0.09px;
    }

    &__results-empty-detail {
        color: var(--color-text-primary-default);
        font-size: var(--font-size-xs);
        line-height: var(--font-line-height-xs);
        font-weight: var(--font-weight-regular);
        letter-spacing: 0.1px;
    }

    &__type-results-empty-message {
        padding: 10px 24px;
    }
}

.sw-search-bar__type-item {
    margin: 3px;
    border-radius: $sw-search-bar-types-item-border-radius;
    display: inline-block;
    cursor: pointer;
    padding: 3px;

    &.is--active {
        border: 1px solid;
    }

    @media screen and (max-width: 350px) {
        width: 100%;

        .sw-search-bar__type {
            width: 100%;
            text-align: center;
        }
    }
}
